package cn.edu.scau.cmi.yangzemin.singleton;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class UIController2 {

    @FXML
    private Button button;

    @FXML
    private Label label; 

    @FXML
    private TextField textField;
    
    public void init()
    {
    	button.setOnAction(this::createMarshal);
    }
    
    private void createMarshal(ActionEvent event)
    {
    	if (!label.getText().equals(""))
    	{
    		label.setText(label.getText() + "\n");
    	} 
    	Marshal marshal = Marshal.getInstance(textField.getText());
    	if (marshal == null)
    	{
    		label.setText(label.getText() + "不可以再创建实例了!");
    	}
    	else
    	{
    		label.setText(label.getText() + marshal.getName() + " " + marshal);
    	}
    }
}
